package cn.itcast.mq.listener;

import cn.itcast.mq.config.CommonConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class SpringRabbitListener {

    @RabbitListener(queues = CommonConfig.DIRECT_QUEUE)
    public void listenMessage(String msg) {
        System.out.println("消费者接收到simple.queue的消息：【" + msg + "】");
        System.out.println("消息处理成功");
    }
    @RabbitListener(queues = "simple.queue")
    public void listenSimpleQueue(String msg){
        log.info("消费者接收到simple.queue的消息：哈哈哈", msg);
        //模拟异常
        System.out.println(1/0);
        log.debug("消息处理完成");

    }
}
